package copy;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;

//使用转换流,字符数组读写
public class CopyFileWithConversionStreamArray {
    public static void main(String[] args)
    {
        try(InputStreamReader isr = new InputStreamReader(new FileInputStream("src/main/source.txt"));
            OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream("src/main/destination2.txt"))) {
            char[] buffer = new char[1024];
            int length;
            while((length = isr.read(buffer))!=-1)
            {
                osw.write(buffer,0,length);
            }
        }catch(IOException e)
        {
            e.printStackTrace();
        }
    }
}
